﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LiveMonitor
{
    public partial class MonitorSetting : Form
    {
        public MonitorSetting(LiveMonInfo liveMonInfo)
        {
            InitializeComponent();
            info = liveMonInfo;
        }

        public void SetData()
        {
            this.nudMaxMemLim.Value = info.maxMemoryLimit;
        }

        private void btnSetDefault_Click(object sender, EventArgs e)
        {
            this.nudMaxMemLim.Value = info.defaultMaxMemoryLimit;
            this.DialogResult = DialogResult.Cancel;
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            info.maxMemoryLimit = (int)this.nudMaxMemLim.Value;
            this.DialogResult = DialogResult.Cancel;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            //do nothing
            this.DialogResult = DialogResult.Cancel;
        }

        private void cbEnableRest_CheckedChanged(object sender, EventArgs e)
        {
            if (this.cbEnableRest.Checked)
            {
                this.nudMaxMemLim.Enabled = true;
                info.enabled = true;
            }
            else
            {
                this.nudMaxMemLim.Enabled = false;
                info.enabled = false;
            }
        }

        LiveMonInfo info;
    }
}
